'use strict';
module.exports = (app) => {
  const { STRING, INTEGER, TEXT } = app.Sequelize;
  const Comment = app.model.define('b_comment', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    userId: {
      comment: '用户Id',
      type: INTEGER,
      allowNull: false,
    },
    userName: {
      comment: '作者名',
      type: TEXT('long'),
      allowNull: false,
    },
    userAvatar: {
      comment: '作者头像名',
      type: TEXT('long'),
      allowNull: false,
    },
    beRepliedUserId: {
      comment: '被回复的用户的id',
      type: INTEGER,
      defaultValue: null,
    },
    beRepliedUserName: {
      comment: '被回复的用户的昵称',
      type: TEXT('long'),
      defaultValue: null,
    },
    beRepliedUserAvatar: {
      comment: '被回复的用户的头像',
      type: TEXT('long'),
      defaultValue: null,
    },
    blogId: {
      comment: '博客Id',
      type: INTEGER,
      allowNull: false,
    },
    projectId: {
      comment: '所属项目id',
      type: INTEGER,
      allowNull: false,
    },
    authorId: {
      comment: '作者id',
      type: INTEGER,
      allowNull: false,
    },
    content: {
      comment: '评论内容',
      type: TEXT('long'),
      allowNull: false,
    },
    parentCommentId: {
      comment: '父评论id',
      type: INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
    likeCount: {
      comment: '点赞次数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
  });
  return Comment;
};
